$(function() {
	$('#vue_vm_list div').hide();
	
	var loginedUser = getLoginedUser();
	findBySubjectRoomId(loginedUser.subjectRoomId);
});

var bedRetain = {
	bedRetainId: '',
	elderId: '',
	bedId: '',
	retainStartTime: '',
	retainEndTime: '',
	retainStatus: '',
	createTime: '',
	updateTime: '',
	createId: getLoginedUser()? getLoginedUser().staffId: '',
	updateId: getLoginedUser()? getLoginedUser().staffId: '',
};

var view = {
	data: bedRetain
};

var vue_vm = new Vue({
	el: '#vue_vm',
	data: view
});

function save() {
	view.data.retainStatus = (view.data.retainStatus==''? 0: parseInt(view.data.retainStatus));

	save_basic(path+'/bedRetain/save', {bedRetain:view.data}, function() {
		alert('保存成功');
		findAll();
	});
}

function findBySubjectRoomId(subjectRoomId) {
	if($('#vue_vm_list').length==0) {return;}
	$('#vue_vm_list div').hide();

	find_basic_by_json(path+'/bedRetain/findBySubjectRoomId', {subjectRoomId: subjectRoomId}, function(response) {
		$('#vue_vm_list').html(gl_vue_vm_list_html);
		
		new Vue({
			el: '#vue_vm_list',
			data: {
				todos: response.data
			},
			methods: {
				finish:function(bedRetainId) {
					save_basic_by_json(path+'/bedRetain/finish', {id:bedRetainId}, function() {
						$('#' + bedRetainId + '_finish').hide();
						alert('结束成功');
						window.open('6-2-3-2blcwjs-1.html?bedRetainId=' + bedRetainId);
					});
				}
			}
		});
		
		$('#vue_vm_list div').show();
	});
}

function deleteBatch() {
	deleteBatch_basic(path+'/bedRetain/deleteBatch');
}
